<?php
	require_once('JSON.php');
	require_once('db_connect.php');
	
	$query = "select * from standard_ap";
	$data = mysqli_query($conn, $query)
		or die('standard_ap 가져오는 쿼리 실패');

	$ap_locations = array();
	while ($row = mysqli_fetch_array($data)) {
		$ap_info = array('ap_id' => intval($row['ap_id']),
										'location' => $row['locatename'],
										'mac' => $row['mac']);
		array_push($ap_locations, $ap_info);
	}

	$query = "select * from standard_gps";
	$data = mysqli_query($conn, $query)
		or die('standard_gps 가져오는 쿼리 실패');

	$gps_locations = array();
	while ($row = mysqli_fetch_array($data)) {
		$gps_info = array('gps_id' => intval($row['gps_id']),
										'location' => $row['locatename'],
										'latitude' => doubleval($row['latitude']),
										'longitude' => doubleval($row['longitude']),
										'radius' => doubleval($row['radius']));
		array_push($gps_locations, $gps_info);
	}
	
	$json = new Services_JSON();			
	$totals = array('ap' => $ap_locations, 'gps' => $gps_locations);
	$output = $json->encode($totals);
	echo $output;
	
	mysqli_close($conn);
?>